<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 5, 1)}"/>
<c-rt:set var="hql">
from BlackBook where memberId = ? order by createDate desc
</c-rt:set>
<c-rt:set var="params" value="${pu:addToList('paras', param.memberId)}"/>
<c-rt:set var="blackLists" value="${pu:queryByHql(hql, params, tp)}"/>
<s:actionerror />
<s:actionmessage />
<s:fielderror />

<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
	$().ready(function(){
		
		//锁定
		$("#addBlacklist").click(function(){
			doAR('${midContextPath}/member/blackBook!confirmBlockDialog.do?AJAX=true&refreshZone=tabs-3&blackBook.memberId=${param.memberId}','confirmBlockDialogContainer');
		});
		
		//解除
		$("#unblockButton").click(function() {
			var activeBlackBookId = $("input[name='activeBlackBookId']").val();
			doAR('${midContextPath}/member/blackBook!confirmUnblockDialog.do?AJAX=true&refreshZone=tabs-3&blackBook.memberId=${param.memberId}&blackBook.id=' + activeBlackBookId, 'confirmUnblockDialogContainer');
		});
	});
</script>
<s:if test="%{addBlackBookByMemberIdResultMessage != null && addBlackBookByMemberIdResultMessage != ''}">
	<s:set var="message" value="%{addBlackBookByMemberIdResultMessage}"></s:set>
	<script type="text/javascript">
		alert('${message}');
	</script>
</s:if>
<div class="f-link">
	<s:set name="memberId">
		${param.memberId}
	</s:set>
	<s:if test="%{memberService.isBlackBookAddableByMemberId(#memberId)}">
		<yaodian100:checkPermission permissions="GROUP_A-30-400-000,GROUP_C.02">
			<a href="#" id="addBlacklist" >新增异常记录</a>
		</yaodian100:checkPermission>
	</s:if>
	<s:else>
		&nbsp;
	</s:else>
</div>
<table class="tb-1" width="100%">
	<thead>
		<tr>
			<th>状态</th>
			<th>锁定時間</th>
			<th>锁定者</th>
			<th>锁定原因</th>
			<th>锁定原因描述</th>
			<th>解锁原因</th>
			<th>解锁原因描述</th>
			<th>修改時間</th>
			<th>修改人</th>
			<th></th>
		</tr>
	</thead>
	<c-rt:choose>
		<c-rt:when test="${not empty blackLists}">
			<tbody>
				<c-rt:forEach items="${blackLists}" var="blackList"
					varStatus="rows_index">
					<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
						<td>
							<c-rt:choose>
								<c-rt:when test="${blackList.blockStatus == 'N'}">
									-
								</c-rt:when>
								<c-rt:otherwise>
									${memberBlockStatus.options[blackList.blockStatus].name}
								</c-rt:otherwise>
							</c-rt:choose>
						</td>
						<td>
							<fmt-rt:formatDate value="${blackList.createDate}" pattern="yyyy-MM-dd HH:mm" />
						</td>
						<td>
							${blackList.createUser}
						</td>
						<td>
							${blockReasonMenu.options[blackList.blockReason].name}
						</td>
						<td>
							${blackList.blockReasonDesc}
						</td>
						<td>
							${unblockReasonMenu.options[blackList.unblockReason].name}
						</td>
						<td>
							${blackList.unblockReasonDesc}
						</td>
						<td>
							<fmt-rt:formatDate value="${blackList.modifyDate}" pattern="yyyy-MM-dd HH:mm" />
						</td>
						<td>
							${blackList.modifyUser}
						</td>
						<td>
							<s:set name="blockStatus">
								${blackList.blockStatus}
							</s:set>
							<s:set name="blackBookId">
								${blackList.id}
							</s:set>
							<s:if test="%{#blockStatus == @com.yaodian100.ec.member.service.impl.MemberServiceImpl@BLACK_BOOK_BLOCK_STATUS_YES}">
								<yaodian100:checkPermission permissions="GROUP_A-30-400-000,GROUP_C.01,GROUP_C.02">
									<s:hidden name="activeBlackBookId" value="%{#blackBookId}" ></s:hidden>
									<input type="button" id="unblockButton" value="解除" />
								</yaodian100:checkPermission>
							</s:if>
							<s:else>
								&nbsp;
							</s:else>
						</td>
					</tr>
				</c-rt:forEach>
			</tbody>
		</c-rt:when>
		<c-rt:otherwise>
			<tbody>
				<tr class="bg-yl">
					<td colspan="7">查无资料</td>
				</tr>
			</tbody>
		</c-rt:otherwise>
	</c-rt:choose>
</table>
<input type="hidden" id="memberId" name="memberId" value="${memberId}"/>
<input type="hidden" id="blackListId" name="blackListId" value="${blackList.id}"/>
<pageable:Pageable url="${midContextPath}/member/blackBook!search.do" escapeparams="AJAX,refreshZone" parameter="AJAX=true&refreshZone=tabs-3" formname="NewaBlackListForm" key="tpp"></pageable:Pageable>
<div id="confirmBlockDialogContainer" style="display:none" >
</div>
<div id="confirmUnblockDialogContainer" style="display:none" >
</div>
